package com.example.commom.utils;


import com.example.commom.global.AppVariable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2023-05-24
 * Time: 16:31
 */
public class UserSessionUtils {

    public static Object getUser(HttpServletRequest request) {
        HttpSession session = request.getSession(false);
        if (session != null && session.getAttribute(AppVariable.USER_SESSION_KEY) != null) {
            return session.getAttribute(AppVariable.USER_SESSION_KEY);
        }
        return null;
    }

    public static String getImgCode(HttpServletRequest request) {
        HttpSession session = request.getSession(false);
        if (session != null && session.getAttribute(AppVariable.IMAGE_CHECK_CODE) != null) {
            return (String) session.getAttribute(AppVariable.IMAGE_CHECK_CODE);
        }
        return null;
    }
}
